var app = getApp();

Page({
  data: {
    shop: app.globalData.shop,
  },
  onShareAppMessage: function () {
    return {
      title: this.data.shop.restaurant_name,
      path: 'pages/index/index'
    }
  },
  onCall: function() {
    wx.makePhoneCall({
      phoneNumber: this.data.shop.phone
    })
  },
  onLocation: function() {
    wx.openLocation({
      latitude: this.data.shop.baoye.latitude,
      longitude: this.data.shop.baoye.longitude,
      name: this.data.shop.restaurant_name,
      address: this.data.shop.address,
      scale: 28
    })
  },
  previewItem: function(e){
    var src = e.currentTarget.dataset.src
    wx.previewImage({
      current: src,
      urls: this.data.shop.items
    })
  },
  onLoad: function (options) {
    var that = this
    
    wx.getSystemInfo({
      success: function(res){
        var windowWidth = res.windowWidth
        var imageBoxWidth = windowWidth * 0.92
        var itemSize = imageBoxWidth * 0.954 / 3
        var itemAway = imageBoxWidth * 0.04 / 2
        that.setData({
          windowWidth: windowWidth,
          itemSize: itemSize,
          itemAway: itemAway
        })
      }
    })

  }
})